<template>
	<view>
		<u-image width="100%" height="524rpx" src="/static/image/loginbg.png"></u-image>
		<view class="login">
			<u-form :model="form" ref="uForm">
				<u-input v-model="form.username" border placeholder="请输入用户名" />
				<u-gap height="18" ></u-gap>
				<u-input v-model="form.password" border type="password" placeholder="请输入密码" />
			</u-form>
			<u-gap height="80"></u-gap>
			<u-button type="primary" @click="login">登录</u-button>
			<u-gap height="100"></u-gap>
			<u-button type="primary" plain @click="to_register" >注册</u-button>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//登录信息
				form: {
					username: 'admin',
					password: '123456'
				}
			}
		},
		onLoad: function() {},

		methods: {
			login: function() {
				let _self = this;
				_self.$serverData.app_login(_self, _self.form, function(res) {

					_self.$localMap.put('user', res.data.data.appUser);
					_self.$localMap.put('token', res.data.data.token);
					_self.$localMap.put('login', res.data.data.status);

					_self.$refs.uToast.show({
						title: "登录成功",
						type: 'success'
					});

					_self.$routerTo.page('./index/index', 2);
				});
			},
			to_register: function() {

				this.$routerTo.page('./register');
			}

		},
	}
</script>

<style lang="scss" scoped>
	.login {
		margin: 0 100rpx;
	}
</style>
